import os
import struct

from data_reader.data_reader import data_reader

class or_reader(data_reader):

    def __init__(self, data_dir):
        return data_reader.__init__(self, data_dir)

    def read_scan(self):
        x_arr = []
        y_arr = []
        z_arr = []

        f = open(self.data_dir_ + self.files_[self.index_], "rb")

        while True:
            x_str = f.read(8)
            if x_str == b'':
                break
            y_str = f.read(8)
            z_str = f.read(8)

            x = struct.unpack('d', x_str)[0]
            y = struct.unpack('d', y_str)[0]
            z = struct.unpack('d', z_str)[0]

            x_arr.append(x)
            y_arr.append(y)
            z_arr.append(z)

        self.index_ += 1
        return x_arr, y_arr, z_arr
